<?php

class m120617_194340_clinic extends CDbMigration
{
	public function up()
	{
	    $pk = "int(11) NOT NULL";
	    
	    $this->createTable('Clinic', array(
            'id' => $pk . ' PRIMARY KEY AUTO_INCREMENT',
            'name' => 'string',
        ), 'ENGINE=InnoDB');

	    $this->addColumn('User', 'clinicId', 'int(11)');
	    
	    $this->addForeignKey('fk_User_Clinic', 'User',
	            'clinicId', 'Clinic', 'id');
	}

	public function down()
	{
		$this->dropForeignKey('fk_User_Clinic', 'User');
		$this->dropColumn('User', 'clinicId');
		$this->dropTable('Clinic');
	}
}